Attribute VB_Name = "basCopy"
'*---------------------------------------------------------------
'*
'* ModuleName:     basCopy
'* FileName:       COPY.BAS
'* Date:           July 1998
'* Author:         Ian M. Weatherburn
'* Company:        Mindkey Software Solutions (Pty) Ltd.
'* Copyright:      Copyright (C) 1998 by Mindkey Software Solutions
'*                 All Rights Reserved
'* Description:    Connect to RAS server specified by Branch
'*                 code passed to application on command-line
'*                 (or chosen by the user)
'*---------------------------------------------------------------

Option Explicit

Private objRASConnection As clsConnection
Private strEntryName As String
Private strUserName As String
Private strPassword As String
Private strShareName As String

Public Function ConnectToServer(strEntryName As String) As Boolean
  
  If DialPhoneEntry(strEntryName) Then
    ConnectToServer = True
  Else
    ConnectToServer = False
  End If
    
End Function

Public Sub DisconnectFromServer()
End Sub

Private Function DialPhoneEntry(strEntryName) As Boolean
  Dim intPhoneEntryCount As Integer
  Dim intLoop As Integer
  Dim blnDialResult As Boolean
  
  On Error GoTo ErrorHandler
  
  blnDialResult = True

  intPhoneEntryCount = objRASEngine.PhoneEntries.Count
  
  ' Find Phone Entry to be dialled
  For intLoop = 0 To intPhoneEntryCount - 1
    If objRASEngine.PhoneEntries(intLoop).EntryName = strEntryName Then
      Set objRASConnection = objRASEngine.PhoneEntries(intLoop).DialEntry(True)
      
      Exit For
      
    End If
  Next intLoop
  
  DialPhoneEntry = blnDialResult
  
  Exit Function
  
ErrorHandler:
  Select Case Err.Number
    'RAS error
    Case vbObjectError + 600 To vbObjectError + 750
      Err.Raise objRASEngine.RASError.ErrorNumber, _
                "PGUpload.RASDialPhoneEntry", _
                "Error: " & objRASEngine.RASError.Message
      objRASEngine.RASError.Clear
    'RAS WIN32 error
    Case vbObjectError + 120
      Err.Raise objRASEngine.RASError.ErrorNumber, _
                "PGUpload.RASDialPhoneEntry", _
                "Error: " & objRASEngine.RASError.Message
      objRASEngine.RASError.Clear
    'RAS Initialize error
    Case vbObjectError + 1911
      Err.Raise objRASEngine.RASError.ErrorNumber, _
                "PGUpload.RASDialPhoneEntry", _
                "Error: 1911" & _
                "Ras is not Properly Configured on this machine"
    'RAS could not get version
    Case vbObjectError + 1912
      Err.Raise objRASEngine.RASError.ErrorNumber, _
                "PGUpload.RASDialPhoneEntry", _
                "Error: 1912" & _
                "Could not determine Windows version on this machine"
    'Failed to decrement instance count on RAS DLL
    Case vbObjectError + 1913
      Err.Raise objRASEngine.RASError.ErrorNumber, _
                "PGUpload.RASDialPhoneEntry", _
                "Error: 1913" & _
                "RAS was not properly deinitialized"
    Case vbObjectError + 6
      Err.Raise objRASEngine.RASError.ErrorNumber, _
                "PGUpload.RASDialPhoneEntry", _
                "Error: 1913" & _
                objRASEngine.RASError.Message & vbCrLf & _
                "Often The Result Of An Invalid Connection Handle" & _
                vbCrLf & _
                "Refresh Connections And Try Again If Necessary"
      objRASEngine.RASError.Clear
        
    'VB or unexpected errors
    Case Else
      Err.Raise Err.Number, _
                "PGUpload.RASDialPhoneEntry", _
                "Error: " & Err.Number & _
                Err.Message
  End Select
  
  blnDialResult = False
  
  Resume Next
End Function


